/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package symulatorwindy;

import java.util.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;
import javax.swing.JTextArea;

/**
 *
 * @author głodoś
 */
public class WindowHandler extends Handler {
  private JTextArea window = null;


  public WindowHandler(JTextArea window) {
    setLevel(Level.ALL);
    this.window = window;
    setFormatter(new SimpleFormatter());
  }


  public synchronized void publish(LogRecord record) {
    String message = null;
    message = getFormatter().format(record);
    window.append(record.getMessage()+"\n");
    window.setCaretPosition(window.getDocument().getLength());
  }

  public void close() {
  }

  public void flush() {
  }
}
